package GearCommands;

import Gear.Factory;
import Gear.Gear;

import java.io.File;

/**
 * Implementation of the user command ls.
 * List all files into gear path.
 *
 * @author Davi Mendes
 */
public class GearCommandLs implements GearCommand {

    @Override
    public void execute(String[] args, Gear gear) {
        File gearDirectory = Factory.getInstance().getSettings().getGearPath().toFile();

        @SuppressWarnings ("MismatchedReadAndWriteOfArray") File[] files = gearDirectory.listFiles();

        System.out.println(String.format("%-60s - %10S", "<FILE NAME>", "<SIZE>"));
        for (File f : files) {
            System.out.println(String.format("%-60s - %10dB", f.getName(), f.length()));
        }
        System.out.println();
    }
}
